mui.init();
mui.plusReady(function() {
	//	window.addEventListener('refreshdom', function(event) {
	//		console.log(event.detail.val);
	//		userindex.reqcode(event.detail.val);
	//	})
	var userindex = new Vue({
		el: "#app",
		data: {
			data1: [{
				"id": "0",
				"name": "全球"
			}],
			data3: [{
				"id": "0",
				"name": "全部分类"
			}],
			postData: {
				brand_id: '',
				goods_type: ''
			},
			list: []

		},
		mounted: function() {
			var _this = this;
			app.postUrl(apiurl + 'Mall/goodsparam.html', {}, function(res) {
				console.log(JSON.stringify(res))
				var tempdata1 = res.data.data1;
				for(var p in tempdata1) {
					_this.data1.push(tempdata1[p]);
				}
				
				var tempdata3 = res.data.data3;
				for(var i in tempdata3){
					_this.data3.push(tempdata3[i]);
					console.log(JSON.stringify(_this.data3))
				}
				
				_this.postData.brand_id = 0;
				_this.postData.goods_type = 0;
			})
			_this.$nextTick(function() {
				_this.cartView();
			});

		},
		methods: {
			cartView: function() {
				var _this = this;
				app.postUrl(apiurl + 'Mall/goodslist.html', _this.postData, function(res) {

					if(res.status === 1) {
						_this.list = res.data;
					}
				})
			},
			refresh: function(done) {
				done();
			},
			infinite: function(done) {
				done();
			},
			selectBrand: function(id) {
				this.postData.brand_id = id;
				this.cartView();
			},
			selectGoods: function(id) {
				this.postData.goods_type = id;
				this.cartView();
			},
			openwin: function(gid) {
				mui.openWindow({
					url: 'view.html',
					id: 'view',
					extras: {
						name: 'mui',
						nid: gid,
					}
				});
			},

		}

	});

});